#!/system/bin/sh
#############################################
CHANNEL=sd_msm6125
EXE_PATH=/system/bin/
#############################################

##echo 38 > /sys/class/gpio/export
##echo out > /sys/class/gpio/gpio38/direction
##echo 1 > /sys/class/gpio/gpio38/value

##echo 63 > /sys/class/gpio/export
##echo out > /sys/class/gpio/gpio63/direction 
##echo 1 > /sys/class/gpio/gpio63/value
platform=`getprop ro.soc.model`
if [ $platform = "SM6125" ] || [ $platform = "SM7325" ]; then
   /system/bin/simoem &
fi
gps=`getprop persist.local_car.gps`
if [ "$gps" ];then
        echo "no empty"
else
        echo "empty default use local gps data"
        setprop persist.local_car.gps 1
        setprop persist.origin_car.gps 0
fi
##echo "peripheral" > /sys/devices/platform/soc/7000000.ssusb/mode
if [ -f "/data/disable_carplay" ];then
setprop sys.usb.debug.enabled 1
setprop persist.vendor.usb.config "diag,serial_cdev,rmnet,dpl,adb"
echo "peripheral" > /sys/devices/platform/soc/4e00000.ssusb/mode
setprop sys.disable.carplay 1
setprop sys.qcom.main.start 1
while true
do
	sleep 2
done
fi
sleep 3
setprop persist.vendor.usb.config "appleSvcTemp"
insmod /vendor/lib/modules/usb_f_xq_ptp.ko
insmod /vendor/lib/modules/usb_f_xq_hid.ko
insmod /vendor/lib/modules/usb_f_xq_mux.ko
insmod /vendor/lib/modules/usb_f_xq_uac1.ko
insmod /vendor/lib/modules/usb_f_xq_vsc.ko
insmod /vendor/lib/modules/usb_xq_user_hid.ko

mkdir /config/usb_gadget/g1/functions/ptp_sd.usb0
mkdir /config/usb_gadget/g1/functions/audio_sd.usb0
mkdir /config/usb_gadget/g1/functions/hid_sd.usb0
mkdir /config/usb_gadget/g1/functions/mux_sd.usb0
mkdir /config/usb_gadget/g1/functions/vsc_sd.usb0
mkdir /config/usb_gadget/g1/configs/b.2 0770
mkdir /config/usb_gadget/g1/configs/b.2/strings/0x409 0770
mkdir /config/usb_gadget/g1/configs/b.3 0770
mkdir /config/usb_gadget/g1/configs/b.3/strings/0x409 0770
mkdir /config/usb_gadget/g1/configs/b.4 0770
mkdir /config/usb_gadget/g1/configs/b.4/strings/0x409 0770

echo "86364000">/proc/sys/net/core/rmem_max
echo '1' > /config/usb_gadget/g1/configs/b.1/MaxPower
sleep 1
setprop sys.usb.config "appleSvc"
setprop sys.usb.configfs 2
sleep 3
echo "peripheral" > /sys/devices/platform/soc/4e00000.ssusb/mode
export LD_LIBRARY_PATH=/data/data/com.xq.hotfix/lib
$EXE_PATH/mdnsd-shark&
logwrapper $EXE_PATH/SharkCarPlay -c $CHANNEL &
sleep 2
insmod /vendor/lib/modules/snd-aloop.ko

while true
do
   sleep 2000
done
